Skip to content

Feat/affichage swagger#1055

Open
Samuelfaure wants to merge 5 commits intomainfrom
feat/affichage_swagger
Open

Feat/affichage swagger#1055
Samuelfaure wants to merge 5 commits intomainfrom
feat/affichage_swagger

Conversation

@Samuelfaure
Copy link
Copy Markdown

@Samuelfaure Samuelfaure commented Apr 20, 2026

fix datagouv/data.gouv.fr#1906

1e3f3f8 is for testing, will drop before merge unless someone asks me not to

J'ai pas fait de JS ni de vue ni de typescript depuis un bail donc hésitez pas à me remonter les bretelles

Aussi pas testé car je suis pas sûr de votre politique de test mais je peux ajouter des tests

Note: je vais probablement remplacer le filtrage par nom de provider pour les bouquets API E/P avec un filtre coté API E/P

when using asdf as node version manager, .tool-versions
is required
@Samuelfaure Samuelfaure force-pushed the feat/affichage_swagger branch from 5d5a086 to c025711 Compare April 20, 2026 14:07
Blocked by CORS, need to make a proxy in dev environment. Adds:
- nuxt.config.ts: Vite dev proxy for entreprise.api.gouv.fr and
  particulier.api.gouv.fr
- utils/openapi-proxy.ts: client-side URL rewriter that maps external
  swagger URLs to the local dev proxy paths
@Samuelfaure Samuelfaure force-pushed the feat/affichage_swagger branch from c025711 to 9f56088 Compare April 20, 2026 18:14
@Samuelfaure Samuelfaure changed the title [WIP] Feat/affichage swagger Feat/affichage swagger Apr 20, 2026
@maudetes maudetes requested review from maudetes and removed request for estellebertrand April 21, 2026 06:15
Copy link
Copy Markdown
Contributor

@nicolaskempf57 nicolaskempf57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR 🙏🏻

I'm not quite clear on the product /usability side. I find that having multiple banners reduce the purpose of the use of the banner component in the page.

Comment thread components/OpenApi/OpenApiProperties.vue Outdated
Comment thread components/OpenApi/OpenApiProperty.vue Outdated
Comment thread utils/openapi-extract.ts Outdated
Comment thread utils/openapi-extract.ts
@@ -0,0 +1,163 @@
// Generic OpenAPI 2.0 / 3.x extractor.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are both API v2 and v3 required for your use case ?

It would be great if this file could be merged with datagouv-components/src/components/OpenApiViewer/openapi.ts

Copy link
Copy Markdown
Author

@Samuelfaure Samuelfaure Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's meant to be generic for any swagger fed by our data providers so we might need v2 and v3 in principle. Will check if we have a lot of V2 swaggers to manage however

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 21 swagger 2.0 VS 219 OpenAPI 3.0 so probably better to not refactorise for now, WDYT?

</div>

<div class="container space-y-4">
<SimpleBanner
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be added to the existing banner in datagouv-components/src/components/OpenApiViewer/OpenApiViewer.vue ? Or moved to an AccordionGroup ? I find it strange to have many banners stacked

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenAPI Viewer right now is for technical documentation, the current PR is aimed at providing non-tech with business (métier) information.

We could move to an AccordionGroup, I propose to ask @DorineLam for her input in UI/UX if the current up-to-3 banners stack is too much

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, c'est possible pour vous de m'envoyer une preview ou au mini une capture écran ?

Comment thread utils/openapi-bouquet.ts Outdated
@Samuelfaure
Copy link
Copy Markdown
Author

Thanks, will correct all of that 👍 I just arrived on this product and still very junior on those stacks, so feedback is very welcome 🙏

Adds a recursive OpenApiProperty component and an OpenApiProperties
wrapper that fetches the dataservice's OpenAPI YAML, extracts the
response schema for the matching endpoint, and renders the fields as
a structured property tree. Matching uses the dataservice title against
endpoint summaries (Bouquet API Entreprise/Particulier conventions).

Descriptions render as sanitized HTML via DOMPurify. A loader appears
while the YAML is fetched and parsed client-side. The property tree is
hosted in a collapsible "Données renvoyées" banner on the dataservice
page, matching the existing Swagger banner's pattern.
Generalises the property tree to work with any OpenAPI 2.0 or 3.x spec,
not just Bouquet API Entreprise/Particulier. A new utils/openapi-extract
module resolves internal $ref pointers, flattens allOf, takes the first
variant of oneOf/anyOf, and handles both v2 (responses.200.schema) and
v3 (responses.200.content.application/json.schema) response locations.

The Bouquet-specific data-wrapper unwrap and title-based filter become
post-hoc transforms applied only when the title matches the Bouquet
pattern. Non-Bouquet dataservices now render all endpoints with their
HTTP method prefixed (GET, POST, ...) in the heading. The property tree
banner loses its redundant heading and gets a white inner background.
@Samuelfaure Samuelfaure force-pushed the feat/affichage_swagger branch from 9f56088 to dae10e5 Compare April 28, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fiche API : Affichage du swagger pour les métier

3 participants